package com.cc.controller;

import com.cc.entity.SalChance;
import com.cc.service.ISalChanceService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * @author 新梦想.陈超
 * @version 2021.2
 * @Description: {TODO}
 * @date 2022/5/13 下午7:40
 */
@Controller
@RequestMapping("/sale")
@Slf4j
public class SaleController {
    @Resource
    private ISalChanceService iSalChanceService;
    /**
     *
     * @param model 绑定数据的模型对象
     * @param page  页数
     * @param pageSize 每页条数
     * @return
     */
    @RequestMapping("/list")
    public String  list(Model model,
                        @RequestParam(value = "page",defaultValue = "1") int page,
                        @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
        log.info("进入SaleController的list方法，page:{},pageSize:{} ",page,pageSize);
        //TODO 1.调用service处理数据
        PageInfo<SalChance> salePage = iSalChanceService.list(page, pageSize);
        //TODO 2.绑定数据并返回jsp
        model.addAttribute("salePage",salePage);
        return "~sale/list";
    }

}
